package com.yshebkb.sulp.controller;

import com.yshebkb.sulp.domain.RestResponse;
import com.yshebkb.sulp.entity.Role;
import com.yshebkb.sulp.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yshebkb
 * @date 2018/7/29
 */
@RestController
@RequestMapping("/api/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping("/list")
    public List<Role> userList() {
        return roleService.findAll();
    }

    @RequestMapping(value = "/modify", method = {RequestMethod.POST})
    public RestResponse modifyUser(@RequestBody Role role) {
        roleService.updateUser(role);
        return RestResponse.success("修改成功");
    }

    @RequestMapping("/delete/{id}")
    public String delUser(@PathVariable Long id) {
        roleService.deleteById(id);
        return "删除成功";
    }
}
